package com.huaqiang.test.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaqiang.test.pojo.vo.DeviceDataVo;
import com.huaqiang.test.pojo.query.DeviceDataQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.huaqiang.test.pojo.entity.DeviceData;
import com.huaqiang.test.mapper.DeviceDataMapper;
import com.huaqiang.test.service.DeviceDataService;

import java.util.List;
/**
 * 设备数据表 服务实现类
 *
 * @author crelle
 * @since 2025-03-20 04:48:55
 */
@Service
public class DeviceDataServiceImpl extends ServiceImpl<DeviceDataMapper, DeviceData> implements DeviceDataService {

    @Autowired
    private DeviceDataMapper devicedataMapper;

    /**
     * 增加DeviceData
     *
     * @param devicedata
     * @return
     */
    @Override
    public DeviceData create(DeviceData devicedata) {
        super.save(devicedata);
        return devicedata;
    }

    /**
     * 批量增加DeviceData
     *
     * @param devicedatas
     * @return
     */
    @Override
    public List<DeviceData> create(List<DeviceData> devicedatas) {
        super.saveBatch(devicedatas);
        return devicedatas;
    }

    /**
     * 根据id删除DeviceData
     *
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(String id) {
        return super.removeById(id);
    }

    /**
     * 根据id批量删除DeviceData
     *
     * @param ids
     * @return
     */
    @Override
    public boolean deleteByIds(List<String> ids) {
        return super.removeBatchByIds(ids);
    }

    /**
     * 根据id修改DeviceData
     *
     * @param devicedata
     * @return
     */
    @Override
    public boolean update(DeviceData devicedata) {
        return super.updateById(devicedata);
    }

    /**
     * 根据id批量修改DeviceData
     *
     * @param devicedatas
     * @return
     */
    @Override
    public boolean updates(List<DeviceData> devicedatas) {
        return super.updateBatchById(devicedatas);
    }

    /**
     * 自动分页查询DeviceData，仅仅适用于单表查询
     *
     * @param page
     * @return
     */
    @Override
    public Page<DeviceData> pageByCondition(Page<DeviceData> page) {
        LambdaQueryWrapper<DeviceData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (null != page && page.getRecords().size() != 0) {
            DeviceData devicedata = page.getRecords().get(0);
            lambdaQueryWrapper.like(null != devicedata.getId(), DeviceData::getId, devicedata.getId());
        }
        return super.page(page, lambdaQueryWrapper);
    }

    /**
     * 手动分页查询DeviceData，用于多表查询
     *
     * @param pageBean
     * @return
     */
    @Override
    public Page<DeviceDataVo> manualPage(Page<DeviceDataQuery> pageBean) {
        return null;
    }

    /**
     * 查询DeviceData详情
     *
     * @param id
     * @return
     */
    @Override
    public DeviceData queryById(String id) {
        return super.getById(id);
    }

    /**
     * 根据id批量查询DeviceData
     *
     * @param ids
     * @return
     */
    @Override
    public List<DeviceData> queryByIds(List<String> ids) {
        return super.listByIds(ids);
    }

    /**
     * 查询所有DeviceData
     *
     * @return
     */
    @Override
    public List<DeviceData> queryAll() {
        return super.list();
    }
}
